<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //判断闰年的方法：能被4整除并且不能被100整除，或者能被400整除则为闰年
        //要求：如果是闰年返回 true,否则返回false
        //方法一：
        function getLeap(year) {
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                return true;
            } else {
                return false;
            }
        }
        console.log(getLeap(2019));
        // 方法二：
        function getLeap(year) {
            var flag = false;
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                flag = true;
            }
            return flag;
        }
        console.log(getLeap(2020));
    </script>
</head>

<body>

</body>

</html>